<template>
	<view class="wm">
		<!-- 学校列表 -->
		<block v-if="school.length > 0">
			<navigator hover-class="none" class="school" v-for="(item,i) in school" :key="item.id" :url="'/pages/dztk/sxlx?schoolid='+item.id">
				<view class="logo">
					<image :src="item.logo ? logoUrl + item.logo : ''" mode="" class="logo-image"></image>	
				</view>	
				<view class="school_info">
					<view class="school_name">{{item.name}}题库</view>
				</view>
				<view class="right">
					<uni-icons type="right" color="#515151"></uni-icons>
				</view>
			</navigator>
		</block>
		<block v-else>
			<no-data></no-data>
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryObj:{
					pageNumber:1,
					length:20
				},
				school:[],
				isloading:false,
				total:1,
			}
		},
		onLoad(){
			this.getSchool();
		},
		computed:{
			logoUrl:function(){
				return getApp().globalData.portImageUrl +  "schoollogo/";
			}
		},
		methods: {
			async getSchool(){
				//打开节流阀
				this.isloading = true;
				const {data:res} = await uni.$http.post("Schools/getAllSchool",this.queryObj);
				this.isloading = false;
				//请求失败
				if(res.meta.status !== 1) return uni.$showMsg();
				//请求成功
				
				this.school = [...this.school,...res.data];
				this.total = res.total;
			},
			godetail(){
				uni.navigateTo({
					
				})
			}
		},
		/**
		 * 学校列表上拉加载更多
		 */
		onReachBottom(){
			//根据节流阀加载数据
			if(this.isloading) return;
			//让页码值自增+1
			this.queryObj.pageNumber++
			//如果当前pageNumber大于了最大页数则不加载
			if(this.queryObj.pageNumber <= this.total){
				this.getSchool(); //请求数据
			}
		},
	}
</script>

<style lang="scss">
@import "../../static/list.scss";
</style>
